package cn.cjxy.web.servlet.demo1;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 从TwoServlet中取出键和值，并且输出
 * @author huangjie
 * @date 2025/9/26
 */
@WebServlet("/two")
public class TwoServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String user =(String) req.getAttribute("user");
        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().print("从作用域中获取到的值是："+user);
    }
}
